package cz.fit.vutbr.pis2012.augeaswh.control.ekonom.orders;

import java.io.Serializable;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import cz.fit.vutbr.pis2012.augeaswh.managers.OrdersManager;
import cz.fit.vutbr.pis2012.augeaswh.persistence.Order;

@ManagedBean
@ViewScoped
public class OrdersConfirmDeleteDialogBean implements Serializable {
	private static final long serialVersionUID = 1675896215722804475L;
	@EJB
	private OrdersManager om;	
	private Order order;
	
	public String getTitle() {
		return "Deleting order";
	}
	
	public String getQuestion() {
		if(this.order==null)
			return "";
		return "Are you sure you want to delete the order "+order.getName()+"?"; 
	}
	
	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}
	
	public void submit() {
		if(this.order!=null) {
			om.delete(this.order);
			this.order=null;
		}
	}
}
